$(function(){

    $("#login").click(function(){
    	login();
    	return false;
    })
})
function login(){
    
	var username = $("#username").val();
	var password = $("#password").val();
	var code_input = $("#code_input").val();
	var ii = layer.load(2, {shade:[0.1,'#fff']});
	$.ajax({
	    type : "POST",
	    url : "./ajax/login",
	    data : {
	        username : username,
	        password : password,
	        img_code:code_input
	    },
	    dataType : 'json',
	    success : function(data) {
	        layer.close(ii);
	        if(data.code == 200){
	            truemsg(layer,data.msg,function(){
	                location.href="./";
	            });
	        }else{
	            falsemsg(layer,data.msg,function(){
	                refreshCaptcha();//刷新验证码
	            });
	        }
	    },
	    error:function(data){
	        layer.close(ii);
	        falsemsg(layer,"服务器错误！");
	    }
	});
}

